<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var arr = [12, 45, 7, 0];
      function popArr() {
        for (var i = 0; i < arr.length; i++) {
          for (var n = 0; n < arr.length; n++) {
            if (arr[n] > arr[n + 1]) {
              var num = arr[n];
              arr[n] = arr[n + 1];
              arr[n + 1] = num;
            }
          }
        }
        return arr;
      }
      console.log(popArr(arr));
    </script>
  </body>
</html>
